#include "Vector2.h"
#include"Vector3.h"

Vector2::Vector2(double x, double y,double w) :BaseVector(3)
{
	Set(x, y, w);
}

Vector2::Vector2(const Vector2 & v): Vector2(v.GetX(),v.GetY(),v.GetW())
{
}

Vector2::Vector2(const BaseVector & v):BaseVector(3)
{
	double* values = v.GetValues();
	this->SetValues(values);
	delete[]values;
}

Vector2::~Vector2()
{
}

void Vector2::Set(double x, double y, double w)
{
	this->SetX(x);
	this->SetY(y);
	this->SetW(w);
}

void Vector2::SetX(double x)
{
	this->data[0] = x;
}

void Vector2::SetY(double y)
{
	this->data[1] = y;
}

void Vector2::SetW(double w)
{
	this->data[2] = w;
}

double Vector2::GetX() const
{
	return this->data[0];
}

double Vector2::GetY() const
{
	return this->data[1];
}

double Vector2::GetW() const
{
	return this->data[2];
}

Vector2& Vector2::operator=(const Vector2& v)
{
	if (this == &v) return *this;
	double* values = v.GetValues();
	this->SetValues(values);
	delete[] values;
	return *this;
}

Vector2 & Vector2::operator=(const BaseVector & v)
{
	if (this == &v) return *this;
	double* values = v.GetValues();
	this->SetValues(values);
	delete[] values;
	return *this;
}


Vector2 Vector2::FromMatrix(Matrix mat)
{
	double* data = mat.GetValues();
	Vector2 res(data[0], data[1], data[2]);
	delete[]data;
	return res;
}
